# -*- coding: utf-8 -*-

import socket
import threading
import time
import sys
import os
import httplib, urllib, urllib2
import re
import sqlite3
from urlparse import urljoin

def LinkThread(url,lnk):
    headers = { 'User-Agent' : "Kanbix HTTP Monitor" }
    req = urllib2.Request(url, None, headers)
    response = urllib2.urlopen(req)
    print url , ":" , str(response.read())
    return

def ThreadMain():
    t = threading.Thread(target=ThreadServe,args=("http://114.80.151.71/kanbix/ajaxproxy.php?type=zabbixEventsMonitor",1,10))
    t.start()
    while 1:
        time.sleep(60)
    return

def ThreadServe(url,urlid,interval):
    while 1:
        print "."
        try:
            LinkThread(url,"")
            time.sleep(interval)
        except KeyboardInterrupt:
            exit()
    return 

if __name__ == '__main__':
    try:
        print u'-'
        print u'LastUpdate: 20120620 R1'
        print u'MgrServ Ver 0.1.0'
        ThreadMain()
    except KeyboardInterrupt:
        print "\r\nKeyboardInterrupt"
        exit()

